<?php
class Common extends CI_Controller {
	static function common_vendor($index){
		$index = str_ireplace(".","/",$index);
		$path = sprintf("%s/%s/%s.php",APPPATH,"vendor",$index);
		if(is_file($path)){
			require_once $path;
		}else{
			exit("ERROR : $path is not file!!!");
		}
	}
	function alipay_conf($key){
		  $alipay = $this->config->item("alipay");
		  return isset($alipay[$key])?$alipay[$key]:'';
	}
	function req($key){
		return isset($_REQUEST[$key])?$_REQUEST[$key]:'';
	}
    function resp_json($data){
        $this->output->set_header('Content-Type: application/json; charset=utf-8');
        echo json_encode($data);
    }
    function resp_api($data,$code=1000,$msg='success'){
        $this->resp_json([
            "code"=>$code,
            "msg"=>$msg,
            "data"=>$data,
        ]);
    }
	function resp_html($view,$data){
        $this->load->library('parser');
        $html = $this->parser->parse($view,$data);
        echo $html;
    }
}
